package com.fbd.internalcommon.dto;

import com.fbd.internalcommon.constant.CommonStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ResponseResult<T> {
    private int code;
    private String message;
    private T data;

    public static <T> ResponseResult success(T data){
        return new ResponseResult()
                .setMessage(CommonStatusEnum.SUCCESS.getValue())
                .setCode(CommonStatusEnum.SUCCESS.getCode())
                .setData(data);
    }
    public static <T> ResponseResult success(){
        return new ResponseResult()
                .setMessage(CommonStatusEnum.SUCCESS.getValue())
                .setCode(CommonStatusEnum.SUCCESS.getCode());
    }
    public static <T> ResponseResult fail(T data){
        return new ResponseResult().setData(data);
    }

    public static ResponseResult fail(int code , String message){
        return new ResponseResult().setCode(code).setMessage(message);
    }

    public static ResponseResult fail(int code , String message , String data){
        return new ResponseResult().setCode(code).setMessage(message).setData(data);
    }
}
